package com.huawei;
import java.util.*;
/**
 * Created by Z-hong on 2024/7/15.
 */

public class HJ32 {
    public static int res=1;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        char [] arr=str.toCharArray();
        if (arr.length==0){
            System.out.println(0);
            return;
        }

        for (int i = 0; i < arr.length; i++) {
            getDouble(arr,i);
            getSim(arr,i);
        }

        System.out.println(res);

    }

    public static void getDouble(char [] arr,int index){
        if (index==arr.length-1){
            return;
        }
        int count=0;
        int i=index;
        int j=index+1;
        while(i>=0&&j<arr.length){
            if(arr[i]==arr[j]){
                i--;
                j++;
                count+=2;
            }else{
                break;
            }
        }
        res=Math.max(count,res);
    }
    public static void getSim(char [] arr,int index){
        int i=index-1;
        int j=index+1;
        int count=1;
        while(i>=0&&j<arr.length){
            if(arr[i]==arr[j]){
                i--;
                j++;
                count+=2;
            }else{
                break;
            }
        }
        res=Math.max(count,res);
    }
}
